//
//  RHPieChartViewLegend.m
//  RuiHeAppApp
//
//  Created by Yan Chen on 2024/1/10.
//

#import "RHPieChartViewLegend.h"

@implementation RHPieChartViewLegend

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
    }
    return self;
}


- (void)setupUI{
    kWeakSelf;
    [self setBackgroundColor:UIColor.whiteColor];
    [self.layer setCornerRadius:3];
    
    _markLab = [[QMUILabel alloc] init];
    [_markLab.layer setCornerRadius:2.0];
    [_markLab.layer setMasksToBounds:YES];
    [self addSubview:_markLab];
    
    _titleLab = [[QMUILabel alloc] init];
    [_titleLab setFont:[UIFont systemFontOfSize:10]];
    [_titleLab setTextAlignment:NSTextAlignmentLeft];
    [_titleLab setTextColor:FontColor(@"#000000")];
    [self addSubview:_titleLab];
    
    _percentLab = [[QMUILabel alloc] init];
    [_percentLab setFont:[UIFont systemFontOfSize:10]];
    [_percentLab setTextAlignment:NSTextAlignmentLeft];
    [_percentLab setTextColor:FontColor(@"#000000")];
    [self addSubview:_percentLab];
    
    _btn = [QMUIButton buttonWithType:UIButtonTypeCustom];
    [self addSubview:_btn];
    
    [_markLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(10, 10));
        make.left.top.mas_offset(5);
        
    }];
    
    [_titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.markLab.mas_right).offset(5);
        make.centerY.equalTo(weakSelf.markLab);
        make.right.mas_offset(-5);
        make.height.offset(15);
        
    }];
    
    [_percentLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.titleLab);
        make.top.equalTo(weakSelf.titleLab.mas_bottom).offset(3);
        make.bottom.mas_offset(0);
        make.height.offset (15);
    }];
    
    [_btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(0);
        make.right.mas_offset(0);
        make.top.bottom.mas_offset(0);
    }];

   
   
}



@end
